//
//  LYYPlayBarView.m
//  Icar
//
//  Created by dllo on 15/10/24.
//  Copyright © 2015年 小龙侠. All rights reserved.
//

#import "LYYPlayBarView.h"

@implementation LYYPlayBarView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatView];
    }
    return self;
}

- (void)creatView{
    
    self.backView = [[UIView alloc]initWithFrame:CGRectMake(0, 0,WIDTH(375),HEIGHT(64))];
    [self.backView setBackgroundColor:BLUECOLOR];
    [self addSubview:self.backView];
    self.imgView = [[UIImageView alloc]initWithFrame:CGRectMake(WIDTH(5), HEIGHT(5), WIDTH(50), HEIGHT(50))];
    [self.backView addSubview:self.imgView];
    self.imgView.layer.cornerRadius = WIDTH(25);
    self.imgView.layer.borderWidth = .5;
    self.imgView.layer.masksToBounds = YES;
    self.imgView.layer.borderColor = [UIColor whiteColor].CGColor;
    [self.imgView setImage:[UIImage imageNamed:@"iconfont-disc-1"]];
    
    self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH(60), HEIGHT(27), WIDTH(100), HEIGHT(25))];
    [self.nameLabel setTextColor:[UIColor whiteColor]];
    [self.backView addSubview:self.nameLabel];
    [self.nameLabel setText:@"汽车电台"];

    self.dateLabel = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH(60), HEIGHT(5), WIDTH(145), HEIGHT(20))];
    [self.backView addSubview:self.dateLabel];
    [self.dateLabel setText:@"听得见的车生活"];
    [self.dateLabel setTextColor:[UIColor whiteColor]];
    
    self.lastButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.lastButton setFrame:CGRectMake(WIDTH(220), HEIGHT(15), WIDTH(30), HEIGHT(30))];
    [self.lastButton setImage:[UIImage imageNamed:@"iconfont-shangyishou"] forState:UIControlStateNormal];
    [self.backView addSubview:self.lastButton];
    
    self.playButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.playButton setFrame:CGRectMake(WIDTH(270), HEIGHT(15), WIDTH(30), HEIGHT(30))];
    [self.backView addSubview:self.playButton];
    [self.playButton setImage:[UIImage imageNamed:@"iconfont-bofang"] forState:UIControlStateNormal];
    [self.playButton setImage:[UIImage imageNamed:@"iconfont-pause"] forState:UIControlStateSelected];
    
    self.nextButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.nextButton setFrame:CGRectMake(WIDTH(320), HEIGHT(15), WIDTH(30), HEIGHT(30))];
    [self.nextButton setImage:[UIImage imageNamed:@"iconfont-xiayishou"] forState:UIControlStateNormal];
    [self.backView addSubview:self.nextButton];
    
    if ([LYYNightModeHandle shareNightModeHandle].temp == YES) {
        [self.backView setBackgroundColor:[UIColor blackColor]];
    }else{
        [self.backView setBackgroundColor:BLUECOLOR];
    }
    
    if (SCREEN_HEIGHT == 736) {
        [self.dateLabel setFont:[UIFont systemFontOfSize:18.]];
        [self.nameLabel setFont:[UIFont systemFontOfSize:14.]];
    }else if (SCREEN_HEIGHT == 667){
        [self.dateLabel setFont:[UIFont systemFontOfSize:16.]];
        [self.nameLabel setFont:[UIFont systemFontOfSize:12.]];
    }else if (SCREEN_HEIGHT == 568){
        [self.dateLabel setFont:[UIFont systemFontOfSize:14.]];
        [self.nameLabel setFont:[UIFont systemFontOfSize:10.]];
    }else if (SCREEN_HEIGHT == 480){
        [self.dateLabel setFont:[UIFont systemFontOfSize:12.]];
        [self.nameLabel setFont:[UIFont systemFontOfSize:8.]];
    }
}

- (void)getModel:(LYYRadioModel *)model listModel:(LYYListModel *)listmodel{
    if (listmodel.program_title.length == 0) {
        [self.dateLabel setText:listmodel.program_live_time];
    }else{
        [self.dateLabel setText:listmodel.program_title];
    }
    NSLog(@"title = %@",listmodel.program_title);
    [self.nameLabel setText:model.album_name];
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:model.album_imgurl]];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
